package youth;

public class User {
    private String account;
    private String password;
    private String email;

    //构造函数，密码与账号必填，邮箱可选填
    public User(String a, String p, String e) {
        account = a;
        password = p;
        if (e!= null) {
            email = e;
        }
    }
    //用户信息展示
    public void show() {
        System.out.println("账号: " + account);
        System.out.println("密码: " + password);
        if (email!= null &&!email.isEmpty()) {
            System.out.println("邮箱: " + email);
        }
    }
    public static void main(String[] args) {
        // 创建有邮箱的对象
        User user1 = new User("javaUser123", "javaPass123", "javaUser123@example.com");
        // 创建无邮箱的对象
        User user2 = new User("javaUser456", "javaPass456", "");
        user1.show();
        user2.show();
    }
}

